package com.koocloud.electroplatemanage.controller;

import com.koocloud.electroplatemanage.common.pojo.ResponseTemplate;
import com.koocloud.electroplatemanage.pojo.AnalysisItems;
import com.koocloud.electroplatemanage.pojo.OriginItems;
import com.koocloud.electroplatemanage.service.AnalysisItemsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.logging.Logger;

/**
 * @program:electroplatemanage
     * @description:镀槽分析单
 * @author: wjx
 * @create: 2020/11/17 10:57
 */
@RestController
@RequestMapping("/analysisItems")
public class AnalysisItemsController {
    static Logger log = Logger.getLogger("analysisItems");

    @Autowired
    AnalysisItemsService analysisItemsService;

    /**
     * @Description:通过pk查询镀槽分析单一条记录
     * @Param: [pk]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/17
     */
    @RequestMapping(value = "/selectByPk",method = RequestMethod.POST,name = "主键查询")
    public ResponseTemplate selectByPk(@RequestParam(name = "analysisItemsId") String pk){
        return analysisItemsService.selectByPk(pk);
    }

    /*@RequestMapping(value = "/selectAllData",method = RequestMethod.POST,name = "查询所有")
    public ResponseTemplate selectAllData(String page,String limit,AnalysisItems analysisItems){

    }*/

    /**
     * @Description:通过镀槽的编号查询镀槽分析单一条记录
     * @Param: [page,limit  tankNo]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/17
     */
    @RequestMapping(value = "/selectByTankNo",method = RequestMethod.POST,name = "通过镀槽查询")
    public ResponseTemplate selectByTankNo(@RequestParam(name = "tankNo") String tankNo,@RequestParam(name = "limit") String limit,@RequestParam(name = "page") String page){
        if (!StringUtils.isNotEmpty(page)) {
            page = "0";
        }
        if (!StringUtils.isNotEmpty(limit)) {
            limit = "0";
        }
        return analysisItemsService.selectByTankNo(page,limit,tankNo);
    }
    /**
     * @Description:插入一条数据
     * @Param: [pk]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/17
     */
        @RequestMapping(value = "/insert",method = RequestMethod.POST,name = "插入数据")
    public ResponseTemplate insert(@RequestBody AnalysisItems analysisItems){
        return analysisItemsService.insert(analysisItems);
    }

    /**
     * @Description:插入一组数据
     * @Param: [pk]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/17
     */
    @RequestMapping(value = "/batchInsert",method = RequestMethod.POST,name = "批量插入数据")
    public ResponseTemplate batchInsert(@RequestBody List<AnalysisItems> listAnalysisItems){
            return analysisItemsService.batchInsert(listAnalysisItems);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST,name = "插入数据")
    public ResponseTemplate updateByItems(@RequestBody AnalysisItems analysisItems){
        return analysisItemsService.updateByItems(analysisItems);
    }

    /**
     * @Description:更新一组数据
     * @Param: [pk]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/17
     */
    @RequestMapping(value = "/batchUpdate",method = RequestMethod.POST,name = "更新一组数据")
    public ResponseTemplate batchUpdate(@RequestBody List<AnalysisItems> analysisItemsList){
        return analysisItemsService.batchUpdate(analysisItemsList);
    }

    /**
     * @Description:更新一条数据
     * @Param: [pk]
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: wjx
     * @date: 2020/11/17
     */
    @RequestMapping(value = "/oBatchUpdate",method = RequestMethod.POST,name = "更新一组数据")
    public ResponseTemplate oBatchUpdate(@RequestParam(name = "tankNo") String tankNo,@RequestParam(name = "analysisItems") String analysisItems,@RequestBody OriginItems originItems){
        return analysisItemsService.oBatchUpdate( tankNo, analysisItems, originItems);
    }
}
